//
//  TranslateLeftCell.m
//  语音翻译合成Demo
//
//  Created by 王鹏宇 on 2018/2/26.
//  Copyright © 2018年 王鹏宇. All rights reserved.
//

#import "TranslateLeftCell.h"

@implementation TranslateLeftCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
    
    self.languageBtn.layer.cornerRadius = 15;
    self.languageBtn.clipsToBounds = YES;
    [self.languageBtn setBackgroundColor:kThemeColor];
    self.selectionStyle = UITableViewCellSelectionStyleNone;
    self.languageLabel.textColor = kContentColor;
    self.translationLabel.textColor = kSubitleColor;
}

- (IBAction)play:(UIButton *)sender {
    
    if (_delegate && [_delegate respondsToSelector:@selector(playTheSpeech:Translation:)]) {
        
        [_delegate playTheSpeech:self.model.translationStr Translation:self.model.toLanguageType];
        
        sender.userInteractionEnabled = NO;
        dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
            sender.userInteractionEnabled = YES;
        });
    }
}

- (void)configData:(TranslationModel *)model {
    
    self.model = model;
    
    [self.languageBtn setTitle:[MYLocalizedString(model.languageName, nil) substringToIndex:1] forState:UIControlStateNormal];
    self.languageLabel.text = model.languageStr;
    CGFloat defaultH = 21;
  CGFloat height =  [IGUtil getHeightWithText:model.languageStr width:kScreenWidth - 140 lineSpacing:0 font:Font(14) defaultHeight:&defaultH];
    self.languageLabelHeight.constant = height;
    self.translationLabel.text = model.translationStr;
}


- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}



@end
